﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="../Content/scripts/jquery-1.11.1.min.js"></script>
    <script src="../Content/scripts/bootstrap/bootstrap.min.js"></script>

    <script src="../js/pdfobject.js" type="text/javascript"></script>
    <link href="../Content/scripts/plugins/jquery-ui/jquery-ui.min.css" rel="stylesheet" />
    <script src="../Content/scripts/plugins/jquery-ui/jquery-ui.min.js"></script>
    <!-- Bootstrap -->
    <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css" />
    <link href="../Content/styles/font-awesome.min.css" rel="stylesheet" />

    <link href="../Content/adminLTE/css/index.css" rel="stylesheet" />
    <link href="../Content/scripts/plugins/jqgrid/jqgrid.css" rel="stylesheet" />
    <link rel="Shortcut icon" href="../images/favicon.ico" />
    <script src="../Content/scripts/plugins/layout/jquery.layout.js"></script>
    <script src="../Content/scripts/plugins/dialog/dialog.js"></script>
    <link href="../Content/styles/learun-ui.css" rel="stylesheet" />
    <script src="../Content/scripts/plugins/jqgrid/grid.locale-cn.js"></script>
    <script src="../Content/scripts/plugins/jqgrid/jqgrid.min.js"></script>
    <script src="../Content/scripts/utils/learun-ui.js"></script>
    <script src="../Content/scripts/utils/learun-form.js"></script>
    <link href="../css/zTreeStyle/metro.css" rel="stylesheet" />
    <script src="../js/jquery.ztree.all-3.5.min.js"></script>
    <script src="../Content/scripts/plugins/validator/validator.js"></script>
    <script src="RoleInfoJS.js"></script>
    <script src="../js/getUrlParam.js"></script>
    <style>
        html, body {
            height: 100%;
            width: 100%;
        }

        /*.ui-layout .west-Panel {
            border: 1px solid #ccc;
            padding: 0px;
        }*/
        .form .formTitle {
            width: 65px;
            font-size: 9pt;
        }

        .form .formValue {
            width: 230px;
        }
    </style>
</head>
<body>

    <div class="ui-layout" id="layout" style="height: 100%; width: 100%;">
        <div class="ui-layout-west">
            <div class="west-Panel" style="margin: 0px; border-top: none; border-left: none; border-bottom: none;">
                <div style="color:#9f9f9f;padding-top:5px; padding-bottom:5px;padding-left:8px;"><i style="padding-right:5px;" class="fa fa-info-circle"></i><span>填写角色基本信息</span></div>
                <table class="form" id="ruleeditinfo" style="margin-top:10px;">
                    <tr>
                        <th class="formTitle">角色名称<font face="宋体">*</font></th>
                        <td class="formValue">
                            <input id="RoleName" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">所属单位<font face="宋体">*</font></th>
                        <td class="formValue">
                            <input id="CustomName" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" readonly />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle" valign="top" style="padding-top: 4px;">
                            备注
                        </th>
                        <td class="formValue" colspan="3">
                            <textarea id="Remark" class="form-control" style="height: 150px;"></textarea>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="ui-layout-center">

            <div class="center-Panel" style="margin: 0px; border-right: none; border-left: none; border-bottom: none; background-color: #fff; overflow: auto; padding-bottom: 10px;">
                <div style="color:#9f9f9f;padding-top:5px; padding-bottom:5px;padding-left:8px;"><i style="padding-right:5px;" class="fa fa-info-circle"></i><span>选择角色权限</span></div>

                <ul id="tree" class="ztree" style="overflow:auto;"></ul>
            </div>
        </div>
    </div>

    <script>
        var IDS = UrlParam.paramValues("RoleID");
        var RoleID = IDS[0];

        //layout布局
        $('#layout').layout({
            applyDemoStyles: true,
            west: {
                size: $(window).width() * 0.5
            },
            spacing_open: 0,
            onresize: function () {
                $(window).resize()
            }
        });

        //$(".center-Panel").height($(window).height())
        $(".west-Panel").height($(window).height());

        var CustomerNameS = UrlParam.paramValues("CustomerName");
        var CustomerName = CustomerNameS[0];


        var zTree;
        var demoIframe;

        var setting = {
            check: {
                enable: true
            },
            view: {
                //addHoverDom: addHoverDom,
                //removeHoverDom: removeHoverDom,
                dblClickExpand: false,
                showLine: true,
                selectedMulti: false
            },
            data: {
                simpleData: {
                    enable: true,
                    idKey: "id",
                    pIdKey: "pId",
                    rootPId: ""
                }
            },
            callback: {
                beforeClick: function (treeId, treeNode) {
                    var zTree = $.fn.zTree.getZTreeObj("tree");
                    if (treeNode.isParent) {
                        zTree.expandNode(treeNode);
                        return false;
                    } else {
                        demoIframe.attr("src", treeNode.file + ".html");
                        return true;
                    }
                }

            }
        };

        var zNodes = [];//所有节点


        if (CustomerName == '宏大') {
            $.rolejs.initRoleLimitByHongda('EDIT',RoleID);
            //$.rolejs.getRoleInfoByID(RoleID);
        }
        else {
            $.rolejs.initRoleLimitByCustomer('EDIT', RoleID,CustomerName);
            //$.rolejs.getRoleInfoByID(RoleID);
        }

        
        // 保存表单  
        function AcceptClick(grid) {
            if (!$('#ruleeditinfo').Validform()) {
                return false;
            }

            var RoleName = $('#RoleName').val();
            //var CustomName = $('#CustomName').find("option:selected").text();
            var Remark = $('#Remark').val();
            var treeObj = $.fn.zTree.getZTreeObj("tree");
            var checkedNodes = treeObj.getCheckedNodes();
            var selectid = [];
            if (checkedNodes.length <= 0) {
                dialogMsg("请至少选择一种权限", 0);
                return false;
            }
            for (var i = 0; i < checkedNodes.length; i++) {
                selectid.push(checkedNodes[i].id);
            }

            $.rolejs.editRoleInfo(RoleID,RoleName,Remark, selectid, grid);
        }


        // 获取cookie
        function getCookie(c_name) {
            if (document.cookie.length > 0) {
                c_start = document.cookie.indexOf(c_name + "=")
                if (c_start != -1) {
                    c_start = c_start + c_name.length + 1
                    c_end = document.cookie.indexOf(";", c_start)
                    if (c_end == -1) c_end = document.cookie.length
                    return unescape(document.cookie.substring(c_start, c_end))
                }
            }
            return ""
        }

        function loadReady() {
            var bodyH = demoIframe.contents().find("body").get(0).scrollHeight,
                    htmlH = demoIframe.contents().find("html").get(0).scrollHeight,
                    maxH = Math.max(bodyH, htmlH), minH = Math.min(bodyH, htmlH),
                    h = demoIframe.height() >= maxH ? minH : maxH;
            if (h < 530) h = 530;
            demoIframe.height(h);
        }
    </script>
</body>
</html>


